<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<div class="portlet box green">
	<div class="portlet-title">
		<div class="caption">
			<i class="fa fa-gift"></i>
			<c:if test="${staff != null }">取派员编辑</c:if>
			<c:if test="${staff == null }">取派员添加</c:if>
		</div>
  </div>
  <div class="portlet-body form">
  	<form id="staffForm" class="form-horizontal form-bordered" action="/user/save" method="post" enctype="multipart/form-data">
  		<div class="form-group">
        <label class="col-md-3 control-label">姓名:</label>
        <div class="col-md-4">
        	<div class="input-icon right">
	        	<i class="fa"></i>
	          <input type="text" class="form-control" name="name" value="${staff.name}" required maxlength="50"/>
	        </div>
        </div>
      </div>
      
  		<div class="form-group">
        <label class="col-md-3 control-label">手机:</label>
        <div class="col-md-4">
        	<div class="input-icon right">
	        	<i class="fa"></i>
	          <input type="text" class="form-control" name="telephone" value="${staff.telephone}" required maxlength="50"/>
	        </div>
        </div>
      </div>
      
  		<div class="form-group">
        <label class="col-md-3 control-label">单位:</label>
        <div class="col-md-4">
        	<div class="input-icon right">
	        	<i class="fa"></i>
	          <input type="text" class="form-control" name="station" value="${staff.station}" required maxlength="50"/>
	        </div>
        </div>
      </div>
      
  		<div class="form-group">
        <label class="col-md-3 control-label">是否有PDA:</label>
        <div class="col-md-4">
        	<div class="input-icon right">
	        	<i class="fa"></i>
	        	<select class="form-control select2" style="padding: 0;" required name="haspda">
	        		<option value="1" <c:if test="${staff.haspda.equals('1')}">selected</c:if>>是</option>
	        		<option value="0" <c:if test="${staff.haspda.equals('0')}">selected</c:if>>否</option>
	        	</select>
	        </div>
        </div>
      </div>
      
  		<div class="form-group">
        <label class="col-md-3 control-label">取派标准:</label>
        <div class="col-md-4">
        	<div class="input-icon right">
	        	<i class="fa"></i>
	          <input type="text" class="form-control" name="standard" value="${staff.standard}" required maxlength="50"/>
	        </div>
        </div>
      </div>
       <div class="form-actions">
        <div class="col-md-9 col-md-offset-3">
          <button type="button" class="btn btn-primary" onclick="saveUser(this)">
          	<spring:message code="btn.save"></spring:message>
          </button>
          <button type="reset" class="btn btn-default" onclick="cancel()">
          	<spring:message code="btn.return"></spring:message>
          </button>
        </div>
      </div>
      <input type="hidden" name="id" value="${staff.id}">
  	</form>
  </div>
</div>
<script type="text/javascript" src="<c:url value="/static/custom/datepicker-util.js"></c:url>"></script>
<script type="text/javascript">
	
	function saveUser(obj){
		if($('#staffForm').valid()){
			
			var formData = new FormData($('#staffForm')[0]);
			$.ajax({
				type: 'post',
				url: '<c:url value="/staff/save"></c:url>',
				data: formData,
				async: false,  
			    cache: false,  
			    contentType: false,  
			    processData: false, 
				dataType: 'json',
				success: function(data){
					if(data.code == 0) {
						layer.msg(data.message, {shift: 1});
						setTimeout(function(){
							search();
							$(".panel-search").show();
						}, 1200);
					}else{
						layer.msg(data.message, {shift: 6});
					}
				}
			});
		}
	}
</script>